<?php

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;

class StoreCategoryRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'pid'=>'required|numeric',
            'pic'=>'required',
            'cate_name'=>'required|unique:store_category',
            'sort'=>"required|numeric",
            'is_show'=>'required|numeric'
        ];
    }

    public function messages()
    {
        return [
            'pid.required'=>'父级id不能为空',
            'pid.numeric'=>'父级为只能为数值',
            "pic.required"=>'商品分类图标不能为空',
            'cate_name.required'=>'分类名称不能为空',
            'cate_name.unique'=>'分类名称不能重复',
            'sort.required'=>'排序不能为空',
            'sort.numeric'=>'排序只能为数值',
            'is_show.required'=>'是否显示不能为空',
            'is_show.numeric'=>'是否显示不能为数值',
        ];
    }
}
